package com.boomsecret.pattern.decorator.java;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Created by wangjinliang on 2018/1/26.
 */
public class DecoratorStreamDemo {
    public static void main(String[] args) {
        String filePath = "C:/MineProjects/JavaDemo/src/main/java/tt.txt";
        InputStream inputStream = null;
        try {
            inputStream = new LowerCaseInputStream(
                    new FileInputStream(
                            new File(filePath)));
            StringBuilder sb = new StringBuilder();
            byte[] bytes = new byte[1024];
            int len = -1;
            while ((len = inputStream.read(bytes)) != -1) {
                sb.append(new String(bytes, 0, len));
            }
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (inputStream != null) {
                    inputStream.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
